$(document).ready(function(){
	$(".alert").alert('close');
	$('#pwd-form').validate({
	    rules: {
	    	oldpwd: {
	        minlength: 1,
	        required: true
	      },
	      newpwd: {
	    	minlength: 6,
	    	maxlength: 12,
	        required: true
	      },
	      newpwd1: {
	    	  minlength: 6,
		      maxlength: 12,
		      required: true
	      },
	    },
		highlight: function(element) {
			$(element).closest('.control-group').removeClass('success').addClass('error');
		},
		success: function(element) {
			element.text('').addClass('valid').closest('.control-group').removeClass('error').addClass('success');
		},
		submitHandler: function(form) {
			if($('#newpwd').val()!=$('#newpwd1').val()){
				$('#PWDerrormsg').html("两次密码不一致");
	    		$('.alert1').show(500);
	    		return;
			}
			$.ajax({
			    type: 'POST',
			    url: server+"admin/update" ,
			    data: $("#pwd-form").serialize() ,
			    success: function(data){
			    	if(data.status=="success"){
			    		$('.alert1').hide(500);
			    		$('#oldpwd').val("");
			    		$('#newpwd').val("");
			    		$('#newpwd1').val("");
			    		$('#PWDModal').modal('hide');
			    	}else{
			    		$('#PWDerrormsg').html(data.msg);
			    		$('.alert1').show(500);
			    	}
			    } ,
			    error:	function(data){
			    	$('#PWDerrormsg').html("保存失败!请重新登录");
		    		$('.alert1').show(500);
			    },
			    dataType: "JSON"
			});
		}
  });
});
function showChangePwd(){
	$('#PWDModal').modal('show');
}